﻿
config.eventcfg = {		
		setFun: function() {
			var records = this.grid.getSelectionModel().getSelections();
			if (!JxUtil.selectone(records)) return;
			
			var role_id = records[0].get('sys_role__role_id');

			//过滤条件
			var where_sql = 'plet_fun.role_id = ?';
			var where_type = 'string';
			var where_value = role_id;
			
			//显示数据
			var hdcall = function(grid) {
				JxUtil.delay(500, function(){
					//处理树形页面的情况
					if (!grid.isXType('grid')) {
						grid = grid.getComponent(1).getComponent(0);
					}

					//设置外键值
					grid.fkFunId = 'sys_role';
					grid.fkValue = where_value;
					Jxstar.loadData(grid, {where_sql:where_sql, where_value:where_value, where_type:where_type});
				});
			};
		
			var define = Jxstar.findNode('plet_fun');
			//显示数据
			Jxstar.showData({
				filename: define.gridpage,
				title: define.nodetitle, 
				pagetype: 'editgrid',
				nodedefine: define,
				callback: hdcall
			});
		},
    
    	syncRole: function() {
        	var records = this.grid.getSelectionModel().getSelections();
			if (!JxUtil.selectone(records)) return;
			
			var role_id = records[0].get('sys_role__role_id');
        	var role_no = records[0].get('sys_role__role_no');
            if (role_no != 'cloud_admin' && role_no != 'cloud_default') {
                alert('只有[cloud_admin]与[cloud_default]角色才需要同步到其他租户！');
                return;
            }
            
            var params = 'role_id='+ role_id +'&role_code='+ role_no;
				params += '&funid=sys_role&eventcode=syncrole';
			
			//发送请求
			Request.postRequest(params, null);
    	}
		
	};